// pages/jielong/user/user.js
var template = require('../template/tabber/tabber.js');
var app = getApp();
var testURL1 = app.data.testURL;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    onclose_cover:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this;
    template.tabbar("tabBar", 2, this)//0表示第一个tabbar
    wx.getStorage({
      key: 'getuserInfo',
      success: function(res) {
        that.setData({
          userInfo:res.data
        })
      },
    })
    wx.getStorage({
      key: 'isTz',
      success: function(res) {
        console.log(res)
        if(res.data==1){
          that.setData({
            isTz: true
          })
        }else{
          that.setData({
            isTz: false
          })
        }
        
      },
    })
  },
  goorder:function(){
    wx.navigateTo({
      url: '../myorder/myorder',
    })
  },
  goordertype:function(e){
    console.log(e)
    wx.navigateTo({
      url: '../myorder/myorder?type=' + e.currentTarget.dataset.index,
    })
  },
  queryTz:function(){
    wx.navigateTo({
      url: '../querytz/querytz',
    })
  },
  queryBoss:function(){
    wx.navigateTo({
      url: '../queryboss/queryboss',
    })
  },
  gocoupon:function(){
    wx.navigateTo({
      url: '../mycoupon/mycoupon',
    })
  },
  goactivity: function () {
    wx.navigateTo({
      url: '../active/active',
    })
  },
  godaily: function () {
    wx.navigateTo({
      url: '../daily/daily',
    })
  },
  gomember:function(){
    wx.navigateTo({
      url: '../member/member',
    })
  },
  gorank: function () {
    wx.navigateTo({
      url: '../rank/rank',
    })
  },
  gosearch: function () {
    wx.navigateTo({
      url: '../searchorder/searchorder',
    })
  },
  gocheck:function(){
    let that = this
    wx.getStorage({
      key: 'isTz',
      success: function(res) {
        console.log(res)
        if(!res.data){
          wx.navigateTo({
            url: '../myorder/myorder?isTz=' + res.data + '&hexiao=1&type=8',
          })
        }else{
          wx.request({
            url: testURL1+'op=qrcode2',
            data:{
              state:1,
              unionId: app.data.unionId || wx.getStorageSync('unionId'),
              openid: wx.getStorageSync('openid')
            },
            success:function(res){
              console.log(res)
              that.setData({
                onclose_cover: true,
                code_img:res.data.url
              })
            }
          })
        }
       
      },
    })
    
  },
  gomoney:function(){
    wx.navigateTo({
      url: '../commission/commission',
    })
  },
  close_cover: function () {
    this.setData({
      onclose_cover: false
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  go:function(){
    wx.navigateTo({
      url: '../apply_grouper/index',
    })
  },
  gosetting:function(){
    wx.navigateTo({
      url: '../setup/index',
    })
  },
  goArea:function(){
    wx.navigateTo({
      url: '../creatorder/creatorder',
    })
  },
  goods:function(){
    wx.navigateTo({
      url: '../goods_provide/index',
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})